#!/bin/bash
# Run unixbench benchmark

###SHELLPACK preamble unixbench-bench 5.1.3
TESTTIME=15
ITERATIONS=12
TESTLIST=
MAX_THREADS=$NUMCPUS

###SHELLPACK parseargBegin
###SHELLPACK parseargInstall
###SHELLPACK parseargParam   --min-threads      UNIXBENCH_MIN_THREADS
###SHELLPACK parseargParam   --max-threads      UNIXBENCH_MAX_THREADS
###SHELLPACK parseargParam   --iterations	UNIXBENCH_ITERATIONS
###SHELLPACK parseargParam   --workloads	UNIXBENCH_WORKLOADS
###SHELLPACK parseargEnd
###SHELLPACK monitor_hooks

###SHELLPACK check_install_required unixbench-${VERSION}
###SHELLPACK init_complete

echo $UNIXBENCH_WORKLOADS > $LOGDIR_RESULTS/workloads

export UB_TESTDIR=$SHELLPACK_DATA

###SHELLPACK threads_min_max_stride_begin $UNIXBENCH_MIN_THREADS $UNIXBENCH_MAX_THREADS
	for WORKLOAD in $UNIXBENCH_WORKLOADS; do
		mmtests_activity $WORKLOAD-$NR_THREADS
		monitor_pre_hook $LOGDIR_RESULTS $NR_THREADS
		###SHELLPACK iteration_begin $UNIXBENCH_ITERATIONS
			echo Running test $WORKLOAD iteration $ITERATION/$UNIXBENCH_ITERATIONS
			./Run -q -c $NR_THREADS $WORKLOAD 2>&1 | \
				tee $LOGDIR_RESULTS/$WORKLOAD-${NR_THREADS}-${ITERATION}.log \
				|| die Failed ro run unixbench
		###SHELLPACK iteration_end $UNIXBENCH_ITERATIONS
		monitor_post_hook $LOGDIR_RESULTS $NR_THREADS
	done
###SHELLPACK threads_stride_end
exit $SHELLPACK_SUCCESS
